import http from '../utils/request'

export default {
    //登录
    login: (account, pwd) => {
        return http.request({
            url: '/user/login',
            method: 'post',
            data: {
                account,
                pwd
            }
        })
    },
//     查看用户信息
    getUserInfo: () => {
        return http.request({
            url: '/user',
            method: 'get',
        })
    },
//     查询用户自己创建的知识库
    getOwn: () => {
        return http.request({
            url: '/dcLibrary/knowledge/owner',
            method: 'get',
        })
    },
//     查询用户有权限的知识库
    getAll: () => {
        return http.request({
            url: '/dcLibrary/knowledge',
            method: 'get'
        })
    },
//     删除知识库
    deleteHouse: (id) => {
        return http.request({
            url: '/dcLibrary/' + id,
            method: 'delete',
        })
    },
//     添加知识库
    addHouse: (name, description, color, fileType) => {
        return http.request({
            url: '/dcLibrary',
            method: 'post',
            data: {
                name,
                description,
                color,
                fileType
            }
        })
    },
//     添加文件
    addText: (name, description, id, fileType) => {
        return http.request({
            url: '/dcLibrary',
            method: 'post',
            data: {
                name,
                description,
                id,
                fileType
            }
        })
    },
//     查询知识库下的目录总数
    getAllCount: (id) => {
        return http.request({
            url: '/dcLibrary/document/total/' + id,
            method: 'get'
        })
    },
    // 查询知识库信息
    getInfo: (id) => {
        return http.request({
            url: '/dcLibrary/info/' + id,
            method: 'get'
        })
    },
//     获取知识库下面的所有文件
    getTree: (id) => {
        return http.request({
            url: '/dcLibrary/tree?id=' + id,
            method: 'get'
        })
    },
//     保存文档到文库
    saveText: (documentId, content) => {
        return http.request({
            url: '/dcLibrary/save/content/' + documentId,
            method: 'post',
            data: {
                content
            }
        })
    },
//     重命名知识库或设置知识库
    setInfo: (data) => {
        return http.request({
            url: '/dcLibrary',
            method: 'put',
            data
        })
    },
//     分享设置
    setShare: (data) => {
        return http.request({
            url: '/dcLibrary/share/setting',
            method: 'post',
            data
        })
    },
//     添加分享的知识库
    getShareKnow: (data) => {
        return http.request({
            url: '/dcLibrary/share/add',
            method: 'post',
            data
        })
    },
//     校验分享的文档
    getShareDocu: (data) => {
        return http.request({
            url: '/dcLibrary/share/check',
            method: 'post',
            data
        })
    },
// 预览文档
    lookDocu: (id) => {
        return http.request({
            url: '/dcLibrary/preview/document/' + id,
            method: 'get'
        })
    }
}

